package com.woniuxy.utils;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

/**
 * @Author: 马宇航
 * @Todo: 过滤器注册配置类
 * @DateTime: 22/08/26/0026 16:05
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class FilterRegistration {
    @Bean
    public FilterRegistrationBean<TimeFilter> filterFilterRegistrationBean(){
        FilterRegistrationBean<TimeFilter> fiterReg = new FilterRegistrationBean<>();
        //把我们自己写的过滤器 注册到FilterRegistrationBean类中
        fiterReg.setFilter(new TimeFilter());
        //配置拦截的url,添加需要拦截的url
        fiterReg.addUrlPatterns("/*");
        //设置优先级为最高  数值最小
        fiterReg.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return fiterReg;
    }
}
